package com.liushao.controller.admin;


import com.liushao.entity.BorrowInfo;
import com.liushao.entity.vo.BorrowInfoApprovalVO;
import com.liushao.result.Result;
import com.liushao.service.BorrowInfoService;
import com.liushao.util.JwtUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chen
 * @since 2025-01-03
 */
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {

    @Autowired
    private BorrowInfoService borrowInfoService;

//http://localhost/admin/core/borrowInfo/list

    @GetMapping("/list")
    public Result list(){
       List<BorrowInfo> borrowInfoList= borrowInfoService.selectList();

       return  Result.ok().data("list",borrowInfoList);
    }

    //
   // http://localhost/admin/core/borrowInfo/show/4

    @ApiOperation("获取借款信息")
    @GetMapping("/show/{id}")
    public Result show(
            @ApiParam(value = "借款id",required = true)
            @PathVariable Long id

    ){

     Map<String,Object> map= borrowInfoService.getBorrowDetailById(id);

        return  Result.ok().data("borrowInfoDetail",map);
    }


   //
  //  http://localhost/admin/core/borrowInfo/approval

    @PostMapping("/approval")
    public Result approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){
        //判断非空是最基本的你们写

             borrowInfoService.approval(borrowInfoApprovalVO);
             return  Result.ok().message("审批通过!");

    }



}

